<template>
	<view>
		<view class="my-userinfo-container">

			<!-- 头像昵称区域 -->
			<view class="top-box">
				<image src="../../static/设置.png" class="top-box-img" @click="goto('/subUserInfo/setting/setting')"></image>
				<image src="../../static/扫码.png" class="top-Scan-img" @click="Scan"></image>
				<image v-if="userinfo.avatarUrl" :src="userinfo.avatarUrl" class="avatar"
					@click="goto('/subStting/personal-information/personal-information')"></image>
				<image v-else src="../../static/login.jpg" class="avatar"
					@click="goto('/subStting/personal-information/personal-information')"></image>
				<view class="nickname">{{userinfo.nickName}}</view>
			</view>
			<!-- 面板的列表区域 -->
			<view class="panel-list">
				<!-- 第一个面板 -->
				<view class="panel">
					<!-- panel 的主体区域 -->
					<view class="panel-body">
						<!-- panel 的 item 项 -->
						<view class="panel-item" @click="goto('/subCustomer/myEval/myEval')">
							<text>{{getAppraise.length}}</text>
							<text>我的评价</text>
						</view>
						<view class="panel-item" @click="goto('/subUserInfo/collect/collect')">
							<text>{{getCollletLenght}}</text>
							<text>收藏的商品</text>
						</view>
						<view class="panel-item" @click="goto('/subCustomer/balance/balance')">
							<text>{{getBalance}}</text>
							<text>我的余额</text>
						</view>
						<view class="panel-item" @click="goto('/subUserInfo/footmark/footmark')">
							<text>{{getFootmarkLenght}}</text>
							<text>足迹</text>
						</view>
					</view>
				</view>

				<!-- 第二个面板 -->
				<view class="panel">
					<!-- 面板的标题 -->
					<view class="panel-title">我的订单</view>
					<!-- 面板的主体 -->
					<view class="panel-body" @click="goto('/subUserInfo/order/order')">
						<!-- 面板主体中的 item 项 -->
						<view class="panel-item">
							<image src="../../static/待付款.png" class="icon"></image>
							<text>待付款</text>
						</view>
						<view class="panel-item">
							<image src="../../static/待收货-我的.png" class="icon"></image>
							<text>待收货</text>
						</view>
						<view class="panel-item">
							<image src="../../static/退款.png" class="icon"></image>
							<text>退款/退货</text>
						</view>
						<view class="panel-item">
							<image src="../../static/全部订单.png" class="icon"></image>
							<text>全部订单</text>
						</view>
					</view>
				</view>
				<!-- 第三个面板 -->
				<view class="panel">
					<view class="panel-list-item" @click="goto('/subUserInfo/address/address')">
						<text>收货地址</text>
						<u-icon name="arrow-right" color="#000" size="15"></u-icon>
					</view>

					<view class="panel-list-item">
						<button class="panel-list-item " style="background-color: white; width: 100%; padding: 0;"
							open-type="contact">
							<text>联系客服</text>
							<u-icon name="arrow-right" color="#000" size="15"></u-icon>
						</button>
					</view>

					<view class="panel-list-item" @click="goto('/subCustomer/Feedback/Feedback')">
						<text>意见反馈</text>
						<u-icon name="arrow-right" color="#000" size="15"></u-icon>
					</view>
					<view class="panel-list-item" @click="exit">
						<text>退出登录</text>
						<u-icon name="arrow-right" color="#000" size="15"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<myModal v-if="active" contents="确定退出登录吗?" @confirm="confirm" @cancel="cancel"></myModal>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapGetters,
	} from 'vuex'
	export default {
		name: "myUserinfo",
		data() {
			return {
				active: false,
			};
		},
		computed: {
			...mapState('login', ['userinfo']),
			...mapState('footmark', ['footmark']),
			...mapGetters("collect", ["getCollletLenght"]),
			...mapGetters("footmark", ["getFootmarkLenght"]),
			...mapGetters("rechargeComments", ["getBalance"]),
			...mapGetters("rechargeComments", ["getAppraise"])
		},


		methods: {
			//扫码
			Scan(){
				wx.scanCode({
				  success (res) {
				   
				  },
					fail: (res) => {//扫码失败后
					        wx.showToast({
					            title: '扫码失败',
					            icon: 'loading',
					            duration: 1500
					        })
					    }
				})
			},
			//跳转
			goto(goToUrl) {
					// uni.vibrateLong()
				uni.navigateTo({
					url: goToUrl
				})
			},
			...mapMutations('login', ['deleteTokenToStorage']),
			//退出登入
			exit() {
				this.active = true
			},
			confirm() {
					uni.vibrateLong()
				this.deleteTokenToStorage()
				this.cancel()
			},
			cancel() {
				this.active = false
			},

		},
	}
</script>

<style lang="scss">
	.my-userinfo-container {
		height: 100%;
		// 为整个组件的结构添加浅灰色的背景
		background-color: #f4f4f4;

		.top-box {
			height: 400rpx;
			background-color: #c00000;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			position: relative;

			.top-box-img {
				position: absolute;
				top: 10px;
				right: 30px;
				width: 50rpx;
				height: 50rpx;

			}
			.top-Scan-img{
				position: absolute;
				top: 10px;
				left: 30px;
				width: 50rpx;
				height: 50rpx;
			}

			.avatar {
				display: block;
				width: 120rpx;
				height: 120rpx;
				border-radius: 90rpx;
				border: 4rpx solid white;
				box-shadow: 0 2rpx 10rpx black;
			}

			.nickname {
				color: white;
				font-weight: bold;
				font-size: 32rpx;
				margin-top: 20rpx;
			}
		}
	}

	.panel-list {
		padding: 0 20rpx;
		position: relative;
		top: -20rpx;

		.panel {
			background-color: white;
			border-radius: 6rpx;
			margin-bottom: 16rpx;

			.panel-body {
				display: flex;
				justify-content: space-around;

				.panel-item {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-around;
					font-size: 26rpx;
					padding: 20rpx 0;


				}
			}
		}
	}

	.panel-list {
		padding: 0 20rpx;
		position: relative;
		top: -20rpx;

		.panel {
			background-color: white;
			border-radius: 6rpx;
			margin-bottom: 16rpx;

			.panel-title {
				line-height: 90rpx;
				padding-left: 20rpx;
				font-size: 30rpx;
				border-bottom: 2rpx solid #f4f4f4;
			}

			.panel-body {
				display: flex;
				justify-content: space-around;

				.panel-item {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-around;
					font-size: 26rpx;
					padding: 20rpx 0;

					.icon {
						width: 70rpx;
						height: 70rpx;
					}
				}
			}
		}
	}

	.panel-list-item {
		height: 90rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		padding: 0 20rpx;
	}
</style>